home *** CD-ROM | disk | FTP | other *** search
- property spr -- Sprite com botao de scroll, que contem behavior
- property sprTexto, memTexto -- sprite/membro do texto
- property yMin, yMax -- Posicoes minimas e maximas do indicador
- property tempoScroll
- property alturaLinha
- property extras
- property sprDesliga
-
- -- Palavras selecionadas (clicadas)
- property linhasTela, linhasTexto
- property posicao, posicaoMax
- property ativo
-
- -- Descricao da Behavior
- on getBehaviorDescription
- return "Gerencia barra de scroll de texto: behavior deve ser" &¬
- "colocado no indicador da barra de scroll"
- end
-
- on getPropertyDescriptionList
- set p_list = [ ¬
- #sprTexto: [ #comment: "Sprite que contem texto", ¬
- #format: #integer, ¬
- #default: 1 ], ¬
- #memTexto: [ #comment: "Membro que contem texto", ¬
- #format: #string, ¬
- #default: "" ],¬
- #yMin: [ #comment: "Posicao mais alta do indicador de scroll:",¬
- #format: #integer,¬
- #default: 0],¬
- #yMax: [ #comment: "Posicao mais alta do indicador de scroll:",¬
- #format: #integer,¬
- #default: 240],¬
- #ativo: [ #comment: "Inicia ativo (0/1):",¬
- #format: #integer,¬
- #default: 1],¬
- #tempoScroll: [ #comment: "Tempo entre cada linha scrollada:",¬
- #format: #integer,¬
- #default: 0],¬
- #extras: [ #comment: "Extras (1 p/ Scroll do historico):",¬
- #format: #integer,¬
- #default: 0],¬
- #sprDesliga: [ #comment: "Sprites p/ desligar caso nao precise de scroll:",¬
- #format: #list,¬
- #default: []]¬
- ]
- return p_list
- end
-
- on beginSprite me
- set spr = the spriteNum of me
- if ativo = 0 then
- desativa me
- else
- inicializaSprite me
- end if
- end
-
- on desativa me
- set ativo = false
- set the visibility of sprite spr to false
- end
-
-
- -- Inicializacao do sprite
- on inicializaSprite me
- set linhasTexto = the lineCount of member memTexto
- set alturaLinha = the lineHeight of member memTexto
-
-
- set linhasTela = the height of sprite sprTexto / alturaLinha
- set posicao = 0
- if linhasTexto <= linhasTela then
- -- Se tem menos texto que o espaco na tela
- -- nao precisa de scroll
- set ativo = false
- set the visibility of sprite spr to false
- repeat with i = 1 to count(sprDesliga)
- set the visibility of sprite getAt(sprDesliga,i) to false
- end repeat
- if extras = 1 then
- puppetSprite 38,true
- set the member of sprite 38 to¬
- member (1 + the number of member "ScrollHistorico")
- end if
- else
- set ativo = true
- set the visibility of sprite spr to true
- if extras = 1 then
- puppetSprite 38,true
- set the member of sprite 38 to¬
- member "ScrollHistorico"
- end if
- set posicaoMax = linhasTexto - linhasTela / 2
- indicador me, 0
- set posicao = 0
- set the scrollTop of member memTexto to 0
- end if
-
- end
-
- -- Acerta posicao do indicador
- on indicador me, linha
- set y = linha * (yMax - yMin) / posicaoMax + yMin
- set the locV of sprite spr to y
- end
-
- -- Mensagens de scroll
- on scrollingCima me
- if not ativo then return
-
- global gCritico
- set gCritico = gCritico + 1
-
- set ultimo = the timer - tempoScroll
- repeat while the mouseDown
- if posicao > 0 and (the timer - ultimo) > tempoScroll then
- -- scrollByLine member memTexto, -1
- set posicao = posicao - 1
- set the scrollTop of member memTexto to ¬
- alturaLinha * posicao
- indicador me, posicao
- set ultimo = the timer
- updateStage
- end if
- sendAllSprites(#idleSprite)
- end repeat
-
- set gCritico = gCritico - 1
- end
-
- on scrollingBaixo me
- if not ativo then return
-
- global gCritico
- set gCritico = gCritico + 1
-
- set ultimo = the timer - tempoScroll
- repeat while the mouseDown
- if posicao < posicaoMax and (the timer - ultimo) > tempoScroll then
- -- scrollByLine member memTexto, +1
- set posicao = posicao + 1
- set the scrollTop of member memTexto to ¬
- alturaLinha * posicao
- indicador me, posicao
- set ultimo = the timer
- updateStage
- end if
- sendAllSprites(#idleSprite)
- end repeat
-
- set gCritico = gCritico - 1
- end
-
- on scrollPaginaCima me
- if not ativo then return
-
- if posicao <= 0 then return
-
- set tmp = linhasTela
- if tmp > posicao then set tmp = posicao
- -- scrollByLine member memTexto, -tmp
- set posicao = posicao - tmp
- set the scrollTop of member memTexto to ¬
- alturaLinha * posicao
- indicador me,posicao
- updateStage
- end
-
- on scrollPaginaBaixo me
- if not ativo then return
-
- if posicao >= posicaoMax then return
-
- set tmp = linhasTela
- if tmp > posicaoMax - posicao then set tmp = posicaoMax - posicao
- -- scrollByLine member memTexto, tmp
- set posicao = posicao + tmp
- set the scrollTop of member memTexto to ¬
- alturaLinha * posicao
- indicador me,posicao
- updateStage
- end
-
- on clickBarra me
- if not ativo then return
-
- global gCritico
- set gCritico = gCritico + 1
-
- if the mouseV > the locV of sprite spr then
-
- scrollPaginaBaixo me
-
- set ultimo = the timer + tempoScroll
- repeat while the mouseDown
- if the timer - ultimo > tempoScroll then
- set ultimo = the timer
- scrollPaginaBaixo me
- end if
-
- sendAllSprites(#idleSprite)
- end repeat
-
- else
- scrollPaginaCima me
-
- set ultimo = the timer + tempoScroll
- repeat while the mouseDown
- if the timer - ultimo > tempoScroll then
- set ultimo = the timer
- scrollPaginaCima me
- end if
-
- sendAllSprites(#idleSprite)
- end repeat
- end if
-
- set gCritico = gCritico - 1
- end
-
- on mouseDown me
- if not ativo then return
-
- -- Arraste
- set posM = the mouseV
- set difV = posM - the locV of sprite spr
-
- repeat while the mouseDown
- if the mouseV <> posM then
- set posM = the mouseV
- set tmp = posM
- if tmp < yMin then set tmp = yMin
- else if tmp > yMax then set tmp = yMax
- set tmp = posicaoMax*(tmp-yMin)/(yMax-yMin)
- set the scrollTop of member memTexto to ¬
- alturaLinha * tmp
- -- scrollByLine member memTexto, tmp - posicao
- set posicao = tmp
- indicador me, posicao
- updateStage
- end if
- end repeat
-
- end